<template>
	<div class="newsinfo-container">
		<h1 class="title">{{ newDetail.title }}</h1>
		<p class="subtitle">
			<span>发表时间：{{ newDetail.add_time | dateFormat }}</span>
			<span>点击：{{ newDetail.click }}</span>
		</p>

		<hr>

		<div class="content" v-html="newDetail.content"></div>

		<!-- 评论部分 -->
		<comments :id="this.id"></comments>
	</div>
</template>

<script>
	import Toast from 'mint-ui'
	// 载入评论子组件
	import comment from '../subcomponents/comment.vue'
	export default {
		data () {
			return {
				id: this.$route.params.id,
				newDetail: {}
			}
		},
		created () {
			this.getNewDetail()
		},
		methods: {
			getNewDetail () {
				this.$http.get('http://www.liulongbin.top:3005/api/getnew/' + this.id).then(result => {
					if (result.body.status === 0) {
						this.newDetail = result.body.message[0]
						
					} else {
						Toast('获取数据失败')
					}
				})
			}
		},
		components: {
			'comments':comment
		}
	}
</script>

<style lang="less" scoped>
	.newsinfo-container{
		padding:0 4px;
		.title {
			text-align:center;
			margin:15px 0;
			color: red;
		}
		.subtitle {
			display: flex;
			justify-content: space-between;
			color: blue;
		}

	}

</style>